package com.hd.trans.homefun

data class FreeTrialCount(var total: Int = 0, private var used: Int = 0){
    fun isHaveFree():Boolean{
        return getFreeCount() > 0
    }
    /**
     * 增加使用次数
     */
    fun consumeFreeTrial(): FreeTrialCount{
        if(isHaveFree()){
            used++
        }
        return this
    }
    /**
     * 剩余次数
     */
    fun getFreeCount():Int{
        val v = total - used
        return if(v <= 0){
            0
        }else{
            v
        }
    }
}
